package com.itany.cloud.util;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author 石小俊
 */
@Data
@Schema(title = "Ajax请求对应的响应数据")
public class ResponseResult {
    @Schema(description = "业务逻辑状态码。详情请参数常量接口ResponseCodeConstant")
    private String responseCode;
    @Schema(description = "响应消息")
    private String message;
    @Schema(description = "可选字段,响应的数据")
    private Object returnObject;

    public static ResponseResult success(){
        ResponseResult result = new ResponseResult();
        result.setResponseCode("1001");
        result.setMessage("成功");
        return result;
    }

    public static ResponseResult success(String message,Object returnObject){
        ResponseResult result = new ResponseResult();
        result.setResponseCode("1001");
        result.setMessage(message);
        result.setReturnObject(returnObject);
        return result;
    }

    public static ResponseResult success(Object returnObject){
        ResponseResult result = new ResponseResult();
        result.setResponseCode("1001");
        result.setMessage("成功");
        result.setReturnObject(returnObject);
        return result;
    }

    public static ResponseResult fail(String message){
        ResponseResult result = new ResponseResult();
        result.setResponseCode("1002");
        result.setMessage(message);
        return result;
    }

}